package com.umakr.ax;

import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 *
 * @author Administrator
 * @date 2017/4/10
 */
public class BaseCondition extends SpringBootCondition {
    @Override
    public ConditionOutcome getMatchOutcome(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Object propertiesName = annotatedTypeMetadata.getAnnotationAttributes(ConditionalOnBase.class.getName()).get("name");
        if (propertiesName != null) {
            String value = conditionContext.getEnvironment().getProperty(propertiesName.toString());
            if (value != null) {
                if("true".equals(value)){
                    return new ConditionOutcome(true, "get properties");
                }
            }
        }
        return new ConditionOutcome(false, "none get properties");
    }
}
